<template>
  <a-card :bordered="false">
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="48">
          <a-col :md="6" :sm="24">
            <a-form-item label="职务类型">
              <j-dict-select-tag
                v-model="queryParam.category"
                placeholder="请选择职务类型！"
                dictCode="position_category"
              />
            </a-form-item>
          </a-col>

          <a-col :xl="10" :lg="11" :md="12" :sm="24">
            <a-form-item label="任职日期">
              <j-date
                placeholder="请选择开始日期"
                class="query-group-cust"
                v-model="queryParam.beginTime_begin"
              ></j-date>
              <span class="query-group-split-cust"></span>
              <j-date
                placeholder="请选择结束日期"
                class="query-group-cust"
                v-model="queryParam.beginTime_end"
              ></j-date>
            </a-form-item>
          </a-col>

          <a-col :md="(!advanced && 4) || 24" :sm="24">
            <span
              class="table-page-search-submitButtons"
              :style="(advanced && { float: 'right', overflow: 'hidden' }) || {}"
            >
              <a-button type="primary" @click="searchQuery">查询</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>

    <a-table
      ref="table"
      size="default"
      rowKey="id"
      :scroll="{ x: true }"
      :columns="columns"
      :dataSource="dataSource"
      :pagination="ipagination"
      :loading="loading"
    >
      <!-- <span slot="action" slot-scope="text, record">
        <a @click="handleReview(record)">查看</a>
        <a-popconfirm
          v-has="'Organization:delete'"
          style="margin-left:10px"
          title="确定删除?"
          @confirm="() => handleDelete(record.id)"
        >
          <a>删除</a>
        </a-popconfirm>
      </span> -->
    </a-table>
  </a-card>
</template>

<script>
import moment from 'moment'
import { merge } from 'lodash'
import { getAction, postAction, deleteAction } from '@/api/manage'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import XImport from '@/components/extends/XImport.vue'
import STable from '@/components/table/'
import JDate from '@/components/jeecg/JDate.vue'
import JDictSelectTag from '@/components/dict/JDictSelectTag.vue'
let statusMap = {
    0:'在职',
    1:'离职'       
}
export default {
  name: 'DeptRoleUserList',
  components: {
    JDate,
    STable,
    XImport,
    JDictSelectTag
  },
  mixins: [JeecgListMixin, mixinDevice],
  data() {
    return {
      visibleImport: false,
      form: null,
      mdl: {},
      url: {
        list: '/sys/userPosition/list',
        add: '/sys/userPosition/add',
        edit: '/sys/userPosition/edit',
        delete: '/sys/userPosition/delete',
        deleteBatch: '/sys/userPosition/deleteBatch',
        exportXlsUrl: '/sys/userPosition/exportXls'
      },
      // 高级搜索 展开/关闭
      advanced: false,
      // 查询参数
      queryParam: {
          
      },
      // 表头
      columns: [
        {
          title: '职务类型',
          align: 'center',
          width: 180,
          dataIndex: 'category_dictText'
        },
        {
          title: '职务',
          align: 'center',
          width: 150,
          dataIndex: 'postCode'
        },
        {
          title: '职级',
          align: 'center',
          width: 150,
          dataIndex: 'postRank_dictText'
        },
        {
          title: '任职时间',
          align: 'center',
          width: 220,
          dataIndex: 'beginTime',
          customRender: function (text) {
            return text?moment(text).format('YYYY-MM-DD'):''
          }
        },
        {
          title: '离职时间',
          align: 'center',
          width: 220,
          dataIndex: 'endTime',
          customRender: function (text) {
            return text?moment(text).format('YYYY-MM-DD'):''
          }
        },
        {
          title: '在职状态',
          align: 'center',
          width: 110,
          dataIndex: 'postStatus',
          customRender: function (text) {
            return statusMap[text]
          }
        }
      ]

    }
  },
  methods: {
    // 查看
    handleReview(record) {},
    // 删除
    handleDelete(id) {},
    batchDel: function() {
      if (this.selectedRowKeys.length <= 0) {
        this.$message.warning('请选择一条记录！')
        return
      } else {
        var ids = ''
        for (var a = 0; a < this.selectedRowKeys.length; a++) {
          ids += this.selectedRowKeys[a] + ','
        }
        var that = this
        this.$confirm({
          title: '确认删除',
          content: '是否删除选中数据?',
          onOk: function() {
            that.loading = true
            delOrganizations({ ids: ids })
              .then(res => {
                if (res.success) {
                  that.$message.success(res.message)
                  that.selectedRowKeys = []
                  that.selectionRows = []
                  that.searchQuery()
                } else {
                  that.$message.warning(res.message)
                }
              })
              .finally(() => {
                that.loading = false
              })
          }
        })
      }
    }
  }
}
</script>
